# 常用数据处理工具
from config import FMT
from utils.assemble import Assemble


def auto_zk_load_data(users: dict, chd: list, dtf: str, source: str, fmt=FMT):
    """
    自动化处理数据
    :param users:
    :param chd:
    :param dtf:
    :param source:
    :param fmt:
    :return:
    """
    result = []
    for uid, dt in chd:
        if dt.strftime(fmt) in dtf:
            result.append(Assemble.check_log(uid, users.get(uid, None), dt=dt, remarks=source))
    return result


def auto_wx_load_data(users: dict, ip: str, dtf: str, fmt="%Y%m%d"):
    """
    自动化微信处理数据
    :param users:
    :param ip:
    :param dtf:
    :param fmt:
    :return:
    """
    result = []


def handle_check_data(users):
    start = 0
    end = 0
    result = []
    # result = get_check_in_data(start, end, u_ids=users)
    check_data = {}
    for rd in result:
        k = f'{rd["userid"]}_{rd["checkin_time"]}'
        if check_data.get(k, "") in "":
            check_data[k] = Assemble.check_log(rd["userid"], users, timestamp=rd["checkin_time"],
                                               remarks=f"打卡地点：{rd['location_title']},打卡设备：{rd['deviceid']}")


if __name__ == '__main__':
    pass
